import { EntitySchema } from '@mikro-orm/core';

export class ImsYzdKpGoodOrderDetail {
  id!: number;
  orderId!: number;
  goodId!: number;
  num: number = 1;
  unitPrice!: string;
  totalOriginalPrice!: string;
  totalPrice!: string;
  couponDiscountPrice!: string;
  signId!: string;
  kmkId?: number = 0;
  goodStr?: string;
  goodsInfo!: unknown;
  isRefund: boolean = false;
  refundState: boolean = false;
  backPrice!: string;
  sign: number = 1;
  addTime!: string;
  updateTime!: string;
  uniacid!: number;
  userId!: number;
  oneMoney!: string;
  twoMoney!: string;
  threeMoney!: string;
}

export const ImsYzdKpGoodOrderDetailSchema = new EntitySchema({
  class: ImsYzdKpGoodOrderDetail,
  properties: {
    id: { primary: true, type: 'number' },
    orderId: { type: 'number', index: 'order_id' },
    goodId: { type: 'number', index: 'good_id' },
    num: { type: 'number', default: 1 },
    unitPrice: { type: 'string', columnType: 'numeric(10,2)', defaultRaw: `0.00` },
    totalOriginalPrice: { type: 'string', columnType: 'numeric(10,2)', defaultRaw: `0.00` },
    totalPrice: { type: 'string', columnType: 'numeric(10,2)', defaultRaw: `0.00` },
    couponDiscountPrice: { type: 'string', columnType: 'numeric(10,2)', defaultRaw: `0.00` },
    signId: { type: 'string', length: 255 },
    kmkId: { type: 'number', nullable: true, default: 0 },
    goodStr: { type: 'string', length: 255, nullable: true },
    goodsInfo: { type: 'unknown', columnType: 'longtext' },
    isRefund: { type: 'boolean', default: false },
    refundState: { type: 'boolean', default: false },
    backPrice: { type: 'string', columnType: 'numeric(10,2)', defaultRaw: `0.00` },
    sign: { type: 'number', default: 1 },
    addTime: { type: 'string', length: 255 },
    updateTime: { type: 'string', length: 255 },
    uniacid: { type: 'number', index: 'uniacid' },
    userId: { type: 'number', index: 'user_id' },
    oneMoney: { type: 'string', columnType: 'numeric(10,2)', defaultRaw: `0.00` },
    twoMoney: { type: 'string', columnType: 'numeric(10,2)', defaultRaw: `0.00` },
    threeMoney: { type: 'string', columnType: 'numeric(10,2)', defaultRaw: `0.00` },
  },
});
